Conditions | 1 |
Paths | 1 |
Total Lines | 53 |
Code Lines | 34 |
Lines | 0 |
Ratio | 0 % |
Changes | 0 |
Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.
For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.
Commonly applied refactorings include:
If many parameters/temporary variables are present:
1 | import { connect as reduxConnect } from 'react-redux'; |
||
17 | const provideServices = (bottle, connect) => { |
||
18 | // Components |
||
19 | bottle.serviceFactory('ShortUrls', ShortUrls, 'SearchBar', 'ShortUrlsList'); |
||
20 | bottle.decorator('ShortUrls', reduxConnect( |
||
21 | (state) => assoc('shortUrlsList', state.shortUrlsList.shortUrls, state.shortUrlsList) |
||
22 | )); |
||
23 | |||
24 | bottle.serviceFactory('SearchBar', SearchBar, 'ColorGenerator'); |
||
25 | bottle.decorator('SearchBar', connect([ 'shortUrlsListParams' ], [ 'listShortUrls' ])); |
||
26 | |||
27 | bottle.serviceFactory('ShortUrlsList', ShortUrlsList, 'ShortUrlsRow'); |
||
28 | bottle.decorator('ShortUrlsList', connect( |
||
29 | [ 'selectedServer', 'shortUrlsListParams' ], |
||
30 | [ 'listShortUrls', 'resetShortUrlParams' ] |
||
31 | )); |
||
32 | |||
33 | bottle.serviceFactory('ShortUrlsRow', ShortUrlsRow, 'ShortUrlsRowMenu', 'ColorGenerator'); |
||
34 | |||
35 | bottle.serviceFactory('ShortUrlsRowMenu', ShortUrlsRowMenu, 'DeleteShortUrlModal', 'EditTagsModal'); |
||
36 | |||
37 | bottle.serviceFactory('CreateShortUrl', CreateShortUrl, 'TagsSelector'); |
||
38 | bottle.decorator( |
||
39 | 'CreateShortUrl', |
||
40 | connect([ 'shortUrlCreationResult' ], [ 'createShortUrl', 'resetCreateShortUrl' ]) |
||
41 | ); |
||
42 | |||
43 | bottle.serviceFactory('DeleteShortUrlModal', () => DeleteShortUrlModal); |
||
44 | bottle.decorator('DeleteShortUrlModal', connect( |
||
45 | [ 'shortUrlDeletion' ], |
||
46 | [ 'deleteShortUrl', 'resetDeleteShortUrl', 'shortUrlDeleted' ] |
||
47 | )); |
||
48 | |||
49 | bottle.serviceFactory('EditTagsModal', EditTagsModal, 'TagsSelector'); |
||
50 | bottle.decorator('EditTagsModal', connect( |
||
51 | [ 'shortUrlTags' ], |
||
52 | [ 'editShortUrlTags', 'resetShortUrlsTags', 'shortUrlTagsEdited' ] |
||
53 | )); |
||
54 | |||
55 | // Actions |
||
56 | bottle.serviceFactory('editShortUrlTags', editShortUrlTags, 'buildShlinkApiClient'); |
||
57 | bottle.serviceFactory('resetShortUrlsTags', () => resetShortUrlsTags); |
||
58 | bottle.serviceFactory('shortUrlTagsEdited', () => shortUrlTagsEdited); |
||
59 | |||
60 | bottle.serviceFactory('listShortUrls', listShortUrls, 'buildShlinkApiClient'); |
||
61 | bottle.serviceFactory('resetShortUrlParams', () => resetShortUrlParams); |
||
62 | |||
63 | bottle.serviceFactory('createShortUrl', createShortUrl, 'buildShlinkApiClient'); |
||
64 | bottle.serviceFactory('resetCreateShortUrl', () => resetCreateShortUrl); |
||
65 | |||
66 | bottle.serviceFactory('deleteShortUrl', deleteShortUrl, 'buildShlinkApiClient'); |
||
67 | bottle.serviceFactory('resetDeleteShortUrl', () => resetDeleteShortUrl); |
||
68 | bottle.serviceFactory('shortUrlDeleted', () => shortUrlDeleted); |
||
69 | }; |
||
70 | |||
72 |